<include file="Inc/html_header" />
<div>
	<form name="addpage" method="post" action="<?php echo U('admin/admin_add');?>" onsubmit="return checkAdmin();">
		<table class="table table-bordered table-hover">
            <thead>
                <tr>
                    <th colspan="2">添加用户</th>
                </tr>
            </thead>
            <tbody>
                <tr>
                    <td width="100" class="tdf">用户名称：</td>
                    <td><input class="form-control form-focus input_text" type="text" id="admin_name" name="admin_name" size="40" style="ime-mode:disabled;" /><span></span></td>
                </tr>
                <tr>
                    <td class="tdf">用户密码：</td>
                    <td><input class="form-control form-focus input_text" type="password" id="admin_password" name="admin_password" size="40" /><span></span></td>
                </tr>
                <tr>
                    <td class="tdf">所属分组：</td>
                    <td class="mySelect"><?php echo $groups;?></td>
                </tr>
                <tr>
                    <td class="tdf" valign="top">用户权限：</td>
                    <td>
                        <div class="node_list"></div>
                    </td>
                </tr>
                <tr>
                    <td class="tdf">&nbsp;</td>
                    <td>
                        <input type="checkbox" id="cka" onclick="checkAll(this, 'auth[]')" />全选&nbsp;&nbsp;&nbsp;
                        <input type="submit" value="添加" class="btn btn-primary" />
                        <input type="button" value="返回" class="btn" onclick="backStep();" />
                    </td>
                </tr>
            </tbody>
		</table>
	</form>
</div>
<script type="text/javascript">
//检查用户表单
function checkAdmin()
{
    var obj_admin_name = $('#admin_name');
    if($.trim(obj_admin_name.val())==''){
        obj_admin_name.css('background-color','#ffc');
        obj_admin_name.next('span').html('<font color=red> 用户名不能为空</font>');
        obj_admin_name.focus();
        return false;
    }else{
        obj_admin_name.css('background-color','#fff');
        obj_admin_name.next('span').html('');
    }

    var obj_admin_password = $('#admin_password');
    if($.trim(obj_admin_password.val())==''){
        obj_admin_password.css('background-color','#ffc');
        obj_admin_password.next('span').html('<font color=red> 密码不能为空</font>');
        obj_admin_password.focus();
        return false;
    }else{
        obj_admin_name.css('background-color','#fff');
        obj_admin_name.next('span').html('');
    }

    if($.trim($('#admin_group_id').val())=='-1'){
        alert('请选择分组');
        return false;
    }
    return true;
}
//得到分组的权限
function getGroupAcl(group_id)
{
    $.ajax({
        url:'/admin/ajax_get_nodes_checkbox',
        data:({'group_id':group_id}),
        dataType:'json',
        success:function(msg){
            $('.node_list').html($(msg.htm));
        }
    })
}

$(function(){
    $(document).on('click', '.cb', function(){
        var flag = false;
        if($(this).is(':checked')){ flag = true; }
        var cbs = $(this).parent().find('input[type="checkbox"]');
        for(var i in cbs){ cbs[i].checked = flag; }
    });
});
</script>
<include file="Inc/html_footer" />